﻿@{
    var totalPrice = 0.0M;
}
<div class="content-wrap">
    <div class="content">
        <!-- shopping-cart-area start -->
        <div class="cart-area ptb-100">
            <form action="/Purchase/BuyWithCart" method="post">
                <div class="container">
                    <div class="row">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">

                            <div class="table-content table-responsive">
                                <table>
                                    <thead>
                                        <tr>
                                            <th class="product-check">选择</th>
                                            <th class="product-price">图片</th>
                                            <th class="product-name">产品名称</th>
                                            <th class="product-price">价格</th>
                                            <th class="product-price">优惠价格</th>
                                            <th class="product-quantity">数量</th>
                                            <th class="product-subtotal">总计</th>
                                            <th class="product-name">删除</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @{
                                            var cartList = ViewData["CartList"] as List<Cart>;
                                            var productList = ViewData["ProductList"] as List<Product>;
                                            if (cartList.Count > 0)
                                            {
                                                foreach (var cart in cartList)
                                                {
                                                    var product = productList.FirstOrDefault(r => r.Id == cart.ProductId);
                                                    totalPrice = totalPrice + (product.PreferentialPrice * cart.Quantity);
                                                    <tr>
                                                        <td class="product-check">
                                                            <input type="checkbox" value="@(cart.Id)" name="chkCart" style="width:25px;height:25px;" checked="checked" onchange="javascript:checkCartProduct(this);" />
                                                        </td>
                                                        <td class="product-thumbnail">
                                                            <a href="/Product/Detail/@(product.Id)"><img src="@(product.ImageUrl)" alt="" width="100" height="100"></a>
                                                        </td>
                                                        <td class="product-name">
                                                            <a href="/Product/Detail/@(product.Id)">@product.Name</a>
                                                            <br />
                                                            <span style="font-size:12px; color:lightgray">备注：@(string.IsNullOrEmpty(cart.Remark) ? "无" : cart.Remark)</span>
                                                        </td>
                                                        <td class="product-price"><span class="amount">@(Math.Round(product.Price, 2))</span></td>
                                                        <td class="product-price"><span class="amount">@(Math.Round(product.PreferentialPrice, 2))</span></td>
                                                        <td class="product-quantity">
                                                            <input value="@(cart.Quantity)" type="number">
                                                        </td>
                                                        <td class="product-subtotal">@(Math.Round(product.PreferentialPrice * cart.Quantity, 2))</td>
                                                        <td class="product-remove">
                                                            <a href="/Cart/Delete/@(cart.Id)">
                                                                <i class="fa fa-times"><font style="font-size:14px;">删除</font></i>
                                                            </a>
                                                        </td>
                                                    </tr>
                                                }
                                            }
                                            else
                                            {
                                                <tr><td colspan="7">购物车暂无商品</td></tr>
                                            }
                                        }
                                    </tbody>
                                </table>
                            </div>

                        </div>
                    </div>
                    <div class="row tax-coupon-div">
                        <div class="col-md-7 col-sm-12 col-xs-12">
                        </div>
                        <div class="col-md-5 col-sm-12 col-xs-12">
                            <div class="cart-total">
                                <ul>
                                    <li class="cart-black">总计<span>@(Math.Round(totalPrice,2))</span></li>
                                </ul>
                                <div class="cart-total-btn">
                                    <div class="cart-total-btn1 f-left">
                                    </div>
                                    <div class="cart-total-btn2 f-right">
                                        <input type="submit" value="购买" class="go-btn" onclick="javascript:return checkSubmit();" style="background-color: rgb(255, 80, 0);border-width:0px;margin-top:5px;" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <!-- shopping-cart-area end -->
    </div>
    <!-- content end -->
</div>
<!-- content-wrap end -->
<script src="~/js/shop.js"></script>